using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;

namespace MatrixFramework.Shared.Contracts.Monitoring
{
    /// <summary>
    /// 健康检查服务接口
    /// 符合ABP vNext规范
    /// </summary>
    public interface IHealthCheckAppService : IApplicationService
    {
        /// <summary>
        /// 获取简单健康状态
        /// </summary>
        /// <returns>健康状态</returns>
        Task<SimpleHealthCheckDto> GetSimpleHealthAsync();

        /// <summary>
        /// 获取详细健康检查报告
        /// </summary>
        /// <returns>详细健康检查报告</returns>
        Task<DetailedHealthCheckDto> GetDetailedHealthAsync();

        /// <summary>
        /// 获取特定组件的健康状态
        /// </summary>
        /// <param name="componentName">组件名称</param>
        /// <returns>组件健康状态</returns>
        Task<ComponentHealthDto> GetComponentHealthAsync(string componentName);
    }

    /// <summary>
    /// 简单健康检查DTO
    /// </summary>
    public class SimpleHealthCheckDto
    {
        public string Status { get; set; } = string.Empty;
        public DateTime Timestamp { get; set; }
        public string? TraceId { get; set; }
    }

    /// <summary>
    /// 详细健康检查DTO
    /// </summary>
    public class DetailedHealthCheckDto
    {
        public string Status { get; set; } = string.Empty;
        public DateTime Timestamp { get; set; }
        public TimeSpan TotalDuration { get; set; }
        public Dictionary<string, ComponentHealthDto> Components { get; set; } = new();
        public string? TraceId { get; set; }
    }

    /// <summary>
    /// 组件健康状态DTO
    /// </summary>
    public class ComponentHealthDto
    {
        public string Status { get; set; } = string.Empty;
        public string? Description { get; set; }
        public TimeSpan Duration { get; set; }
        public Dictionary<string, object> Data { get; set; } = new();
        public string? Exception { get; set; }
    }
}